// 测试TID正则表达式逻辑
const testCases = [
  // 标准TID格式
  "2024-01-15 10:30:45 [INFO] TID:abc123.def456.ghi789 [service.SBYBaseService:70] Processing request",
  
  // 没有TID:前缀的TID格式
  "2024-01-15 10:30:45 [INFO] [fcdfba1a21214a8e97c7d8fd1a8aa287.1161.17544505317727189] [service.SBYBaseService:70] Processing request",
  
  // 混合格式
  "2024-01-15 10:30:45 [ERROR] TID:abc123 [fcdfba1a21214a8e97c7d8fd1a8aa287.1161.17544505317727189] [service.SBYBaseService:70] Error occurred",
  
  // 只有没有前缀的TID
  "2024-01-15 10:30:45 [WARNING] [fcdfba1a21214a8e97c7d8fd1a8aa287.1161.17544505317727189] merId=1749611201012113",
  
  // 复杂格式
  "2024-01-15 10:30:45 [FATAL] [fcdfba1a21214a8e97c7d8fd1a8aa287.1161.17544505317727189] (com.cn.yft.ora.bank.sby.service.SBYBaseService:70) Critical error"
]

console.log("=== TID 正则表达式测试 ===")

testCases.forEach((testCase, index) => {
  console.log(`\n测试 ${index + 1}:`)
  console.log(`输入: ${testCase}`)
  
  // 匹配没有TID:前缀的TID格式 [xxx.xxx.xxx]
  const tidRegex = /\[([a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*(\.[0-9]+)*)\]/g
  let match
  let foundTIDs = []
  
  while ((match = tidRegex.exec(testCase)) !== null) {
    const content = match[1]
    
    // 检查是否不是标准的TID格式
    if (!content.startsWith('TID:') && !content.startsWith('tid:')) {
      // 检查是否不是已知的日志级别
      const isLogLevel = /^(FATAL|ERROR|INFO|WARNING|DEBUG|WARN)$/i.test(content)
      if (!isLogLevel) {
        foundTIDs.push({
          full: match[0],
          content: content,
          index: match.index
        })
      }
    }
  }
  
  if (foundTIDs.length > 0) {
    console.log("✓ 找到 TID 格式:")
    foundTIDs.forEach(tid => {
      console.log(`  - "${tid.full}" (内容: "${tid.content}")`)
    })
  } else {
    console.log("✗ 未找到 TID 格式")
  }
})
